//
//  DataCenter.swift
//  1010
//
//  Created by 米明 on 15/7/23.
//  Copyright (c) 2015年 米明. All rights reserved.
//

import UIKit

class DataCenter: NSObject {
    
    class func setNowScore(score:Int) {
        let df = UserDefaults.standard
        df.set(score, forKey: "nowScore")
        df.synchronize()
        //存入最高分
        DataCenter.setBestScore(score: score)
    }
    
    class func nowScore() -> Int {
        let df = UserDefaults.standard
        return df.integer(forKey: "nowScore")
    }
    
    class func setBestScore(score: Int) {
        
        let oldScore = self.getBestScore()
        
        if score > oldScore {
            let df = UserDefaults.standard
            df.set(score, forKey: "Best")
        }
    }
    
    class func getBestScore() -> Int {
        
        let df = UserDefaults.standard
        return df.integer(forKey: "Best")
    }
    
    class func setMusicSwitch(isOn:Bool) {
        let df = UserDefaults.standard
        df.set(isOn, forKey: "Music")
        df.synchronize()
    }
    
    class func  getMusicSwitch() -> Bool {
        let df = UserDefaults.standard
        return df.bool(forKey: "Music")
    }
    
    class func setSun(isSun:Bool) {
        let df = UserDefaults.standard
        df.set(isSun, forKey: "Sun")
        df.synchronize()
    }
    
    class func  getSun() -> Bool {
        let df = UserDefaults.standard
        return df.bool(forKey: "Sun")
    }
}
